package common

import "github.com/gin-gonic/gin"

type JsonResult struct {
	Code  int         `json:"code"`
	Msg   interface{} `json:"msg"`
	Data  interface{} `json:"data"`
	Count int         `json:"count"`
}

func ReturnSuccess(c *gin.Context, code int, msg interface{}, data interface{}, count int64) {
	c.JSON(200, JsonResult{
		Code:  code,
		Msg:   msg,
		Data:  data,
		Count: int(count),
	})
}

func ReturnError(c *gin.Context, code int, msg interface{}) {
	c.JSON(200, JsonResult{
		Code: code,
		Msg:  msg,
	})
}
